/*
 * features.c
 *
 *  Created on: Mar 23, 2013
 *      Author: lcad
 */
#include <opencv/cv.h>
#include <opencv/highgui.h>

CvSeq*
detect_features(IplImage* img)
{
	CvMemStorage* storage = cvCreateMemStorage(0);
	CvSeq* keypoints = 0;

	keypoints = cvGetStarKeypoints(img, storage, cvStarDetectorParams(45));
	return keypoints;
}


void
feature_matching()
{

}


void
draw_features(IplImage* img, CvSeq* features)
{
	int i;

	for(i = 0; i < (features ? features->total : 0); i++)
	{
		CvStarKeypoint kpt = *(CvStarKeypoint*) cvGetSeqElem(features, i);

		int r = kpt.size / 2;

		cvCircle(img, kpt.pt, r, CV_RGB(0,255,0));

		cvLine(img, cvPoint(kpt.pt.x + r, kpt.pt.y + r), cvPoint(kpt.pt.x - r, kpt.pt.y - r), CV_RGB(0,255,0));
		cvLine(img, cvPoint(kpt.pt.x - r, kpt.pt.y + r), cvPoint(kpt.pt.x + r, kpt.pt.y - r), CV_RGB(0,255,0));
	}
}
